﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Persistencia
{
    public class Conexion
    {
        public static SqlConnection Conectar()
        {
            SqlConnection cn;
            string connStr = @"Data Source=MAURO-0D75D26FE\SQLEXPRESS;Initial Catalog=GICA;Integrated Security=True";
            cn = null;

            try
            {
                cn = new SqlConnection(connStr);
                cn.Open();
            }
            catch (SqlException)
            {
                if (cn.State == ConnectionState.Open)
                    cn.Close();
                throw;
            }
            return cn;
        }

        public static void Desconectar(SqlConnection cn)
        {
            cn.Close();
        }
    }
}
